local skel = fk.CreateSkill {
  name = "rmt__tianshi"
}

Fk:loadTranslationTable{
  ["rmt__tianshi"] = "天视",
  [":rmt__tianshi"] = "你可以打出【杀】抵消目标为你的基本或普通锦囊牌，使用者也可以如此做，直到一方未如此做。",

  ["#rmt__tianshi-slash"] = "天视：你可以打出【杀】抵消 %src 的%arg",
  ["#rmt__tianshi-slashback"] = "天视：你可以打出【杀】防止 %src 抵消%arg",

  ["$rmt__tianshi1"] = "惟天惠民，惟辟奉天！恭天承命，肆予东征。",
  ["$rmt__tianshi2"] = "独夫自绝于天，上帝弗顺，祝降时丧！",
}

skel:addEffect(fk.PreCardEffect, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.to == player
      -- 理论只有伤害类基本牌才需要被响应吧……
      and ((data.card.is_damage_card and data.card.type == Card.TypeBasic) or data.card:isCommonTrick())
      and not data.nullified and
      not (data:isDisresponsive(player) or data:isUnoffsetable(player))
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local from = data.from -- 注意可能没有from
    local first, success = false, false
    local responsers = { player, from }
    local num = 1
    while true do
      local current = responsers[num]
      if current == nil or current.dead then break end
      local prompt = (num == 1 and "#rmt__tianshi-slash:"..from.id or "#rmt__tianshi-slashback:"..player.id)
      .. "::"..data.card:toLogString()
      local response = room:askToResponse(current, {
        skill_name = skel.name, pattern = "slash", prompt = prompt,
        event_data = (current == player) and data or nil,
      })
      if response then
        if not first then
          first = true
          player:broadcastSkillInvoke(skel.name)
          room:notifySkillInvoked(player, skel.name, "defensive")
        end
        room:responseCard(response)
      else
        break
      end
      success = current == player
      num = num % 2 + 1
    end
    data.nullified = success
  end,
})

return skel
